import java.math.BigDecimal;
import java.util.Date;

import any.Any;
import any.impl.SimpleTypeAnything;
import any.util.TypeRegistry.Priority;
import any.util.TypeRegistry.SimpleTypeAnyCreator;


@SuppressWarnings("serial")
class MoneyAny extends SimpleTypeAnything<Money> {

    MoneyAny(Money contents) {
	    super(contents);
    }

    public Any toAny() throws UnsupportedOperationException {
    	return new MoneyAny(contents);
    }
    
    public Boolean asBool(Boolean defaultValue) {
	    return defaultValue;
    }

    public Date asDate(Date defaultValue) {
	    return defaultValue;
    }

	@Override
    protected BigDecimal asBigDecimalImpl() {
	    return null;
    }

	@Override
    protected Double asDoubleImpl(Number defaultValue) {
	    return null;
    }
	
	static class Creator implements SimpleTypeAnyCreator {

        public Priority priority() {
	        return Priority.DEFAULT;
        }

        public boolean canCreateFrom(Object obj) {
			return (obj instanceof Money);
        }

        public SimpleTypeAnything<?> createFrom(Object obj) {
			return new MoneyAny((Money)obj);
        }
		
	    public SimpleTypeAnything<?> parse(String str) {
	        if (str.toLowerCase().startsWith("money")) {
	        	return new MoneyAny(new Money("CHF", BigDecimal.valueOf(13.99)));
	        } else {
	        	return null;
	        }
	    }
	}
    
}
